
import java.time.LocalTime;

public class ConstantTemperatureWaterTank {
    private boolean isTankWorking = false;
    private boolean isTankDamaged = false;
    private double currentTemperature = 25;
    private double currentWaterLevel = 0;

    public void start() {
        while (true) {
            if (isTankWorking && !isTankDamaged) {
                if (currentTemperature < 20) {
                    if (currentWaterLevel > 0) {
                        turnOnHeatingElement();
                        currentTemperature += 1.5;
                        currentWaterLevel -= 0.1;
                    } else {
                        System.out.println("Water tank is empty!");
                    }
                } else if (currentTemperature >= 20 && currentTemperature < 100) {
                    if (currentWaterLevel > 0) {
                        turnOnHeatingElement();
                        currentTemperature += 1.5;
                    } else {
                        System.out.println("Water tank is empty!");
                    }
                } else if (currentTemperature >= 100) {
                    turnOffHeatingElement();
                    System.out.println("Water temperature reached 100 degrees. Heating element turned off.");
                }
            } else if (isTankDamaged) {
                System.out.println("Water tank is damaged. Please repair it.");
            } else {
                System.out.println("Water tank is not working. Please start it.");
            }

            if (LocalTime.now().equals(LocalTime.of(23, 0))) {
                turnOffHeatingElement();
                isTankWorking = false;
                System.out.println("Water tank is in sleep mode now.");
            } else if (LocalTime.now().equals(LocalTime.of(7, 0))) {
                isTankWorking = true;
                System.out.println("Water tank is automatically started in the morning.");
            }
        }
    }

    public void turnOnHeatingElement() {
        System.out.println("Heating element is turned on. Current temperature: " + currentTemperature);
    }

    public void turnOffHeatingElement() {
        System.out.println("Heating element is turned off. Current temperature: " + currentTemperature);
    }

    public void repairTank() {
        isTankDamaged = false;
        System.out.println("Water tank is repaired and ready to use.");
    }

    public static void main(String[] args) {
        ConstantTemperatureWaterTank tank = new ConstantTemperatureWaterTank();
        tank.start();
    }
}





